#coding:utf-8

import MySQLdb
import datetime,time

class MySqlStore(object):
    def __init__(self,prop):
        conn = MySQLdb.connect(host=prop['HOST'],port=prop['PORT'],\
                               user=prop['USER'],passwd=prop['PASSWD'],\
                               )
        conn.autocommit(True)
        conn.select_db(prop['DB_NAME'])
        self.conn = conn
        self.cursor = self.conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
        self.cursor.execute("set character_set_client=utf8")
        self.cursor.execute("set character_set_results=utf8")
        self.cursor.execute("set character_set_connection=utf8")
 
    def getAll(self):
        line = 'SELECT * FROM article_dup_item_pair'
        self.cursor.execute(line)
        rs = self.cursor.fetchall()
        return rs


def initMySqlStore():
    prop = {}
    prop['HOST'] = '10.4.16.228'
    prop['PORT'] = 3306
    prop['USER'] = 'ssro'
    prop['PASSWD'] = '517nrm'
    prop['DB_NAME'] = 'ss_article'
    store = MySqlStore(prop)
    return store

if __name__ == '__main__':

    print 'HI'

    store = initMySqlStore()

    rs = store.getAll()
    print len(rs)

